<!DOCTYPE html>
<html xmlns:v-on="http://www.w3.org/1999/xhtml" xmlns:>
<head>
    <meta charset="utf-8"/>
    <title>事件处理 v-on示例2</title>
    <script src="js/vuejs-2.5.16.js"></script>
</head>
<body>
<div id="app">
    <input type="text" v-on:keydown="fun2('good',$event)">
    <input type="text" @keydown="fun('fuck')">
    {{mass}}
</div>
<script>
    new Vue({
        el: '#app', //表示当前vue对象接管了div区域
        methods: {
            fun2: function (msg, event) {
                if (!((event.keyCode >= 48 && event.keyCode <= 57) || event.keyCode == 8 || event.keyCode == 46)) {
                    event.preventDefault();
                }
            },
            fun:function (msg) {
                this.mass = msg;
                console.log(msg);
            }
        }
    });
</script>
</body>
</html>